<?php

session_start();

// Include i file necessari
include('inc/config.inc.php');
include('inc/template.inc.php');
include('inc/db.inc.php');
include('inc/check.inc.php');

// Recupera l'ID del personaggio.
$user_id	= $_GET['id'];
$skillslist	= '';

// Recupera il nome del personaggio.
if($r1 = $db -> query("SELECT user_name, user_surname FROM users WHERE user_id ='$user_id'"))
{
	$rd1 = $r1 -> fetch_assoc();
	
	$user_name = htmlentities($rd1['user_name']);
	$user_surname = htmlentities($rd1['user_surname']);
	
	$r1 -> close();
}

// Recupera l'elenco delle skills dal database.
if($r2 = $db -> query("SELECT * FROM skillslink WHERE user_id ='$user_id'"))
{
	
	while($rd2 = $r2 -> fetch_assoc())
	{
		$skill_id = $rd2['skill_id'];

		// Recupera i dati della skill
		 if($r3 = $db -> query("SELECT * FROM skills WHERE skill_id ='$skill_id'"))
		 {
			 $rd3 = $r3 -> fetch_assoc();
			 $skillslist .= '<div class="media"><div class="pull-left"><img class="media-object" src="img/locations/default.jpg" alt="..."></div>';
			 $skillslist .= '<div class="media-body"><h4 class="media-heading">' . $rd3['skill_name'] . '</h4><p>' . $rd3['skill_desc'] . '</p>';
			 $skillslist .= '<p><b>Costo della Skill: </b>' . $rd3['skill_cost'] . '</p></div></div>';
		}
	}
	
}

	// Lista delle tag speciali
	$tags = array('temp_title' => $g_name, 'temp_name' => $user_name, 'temp_surname' => $user_surname, 'temp_skillslist' => $skillslist);
	// Carica il template e formatta le tag speciali
	$temp = new template('style/skills.template.html');
	$temp -> replace($tags);
	
	// Visualizza l'output
	echo $temp -> show();
	
	// Chiude la connessione al database
$db -> close();

?>